package everyday;

public class T0831 {
    public String maskPII(String s) {
        if (s.contains("@")){
            int d=s.indexOf("@");
            return Character.toLowerCase(s.charAt(0))+"*****"+Character.toLowerCase(s.charAt(d-1))+s.substring(d).toLowerCase();
        }else{
            StringBuilder t= new StringBuilder();
            for (int i = 0; i <s.length() ; i++) {
                char c=s.charAt(i);
                if (Character.isDigit(c)){
                    t.append(c);
                }
            }
            int l=t.length();
            String left=t.substring(l-4);
            switch (l){
                case 10:
                    return "***-***-"+left;
                case 11:
                    return "+*-***-***-"+left;
                case 12:
                    return "+**-***-***-"+left;
                case 13:
                    return "+***-***-***-"+left;
            }
        }
        return "";
    }
}
